package com.levy.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

//public class SuperMan implements InterfacePerson {
public class SuperMan extends SuperPerson{
	
	public void getName() {
		System.out.println("get name test.");		
	}
	
	public static void main(String[] args) throws SecurityException, NoSuchMethodException {
		getAnnotation();
	}
	
	public static void getAnnotation() {
		try {
			Method method = SuperMan.class.getMethod("getName", null);
			Annotation[] annotations = SuperMan.class.getAnnotations();
			for (Annotation a : annotations){
				System.out.println(a);
			}
			MyAnnotation mr = method.getAnnotation(MyAnnotation.class); 		
			System.out.println(mr);
			
			Method[] methods = SuperMan.class.getDeclaredMethods();
			for (Method m : methods) {
				boolean hasAnnotation = m.isAnnotationPresent(MyAnnotation.class);
				if (hasAnnotation) {
					MyAnnotation annotation = m.getAnnotation(MyAnnotation.class);
					System.out.println("Test( method = " + method.getName()
							+ " , id = " + annotation.myName() + " , description = "
							+ annotation.proxyClass() + " )");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}